import { ConfigService } from '@nestjs/config';
import Redis from 'ioredis';

/*
 * @Author: jingfuu@163.com
 * @Date: 2024-10-07 16:37:23
 * @LastEditTime: 2024-10-07 17:43:06
 * @Description: redis客户端实例化工厂
 */
export const RedisConfiguration = {
  provide: Redis,
  useFactory: (config: ConfigService) => {
    console.log(config);
    return new Redis({
      port: config.get('redis.port'),
      host: config.get('redis.host'),
      db: config.get('redis.db'),
    });
  },
  inject: [ConfigService],
};
